﻿using System;
using System.ComponentModel;
using System.Configuration;
using System.Drawing.Design;
using mki.Backup.Objects.Converters;

namespace mki.Backup.Objects
{
	/// <summary>
	/// Run Process Block
	/// </summary>
	public class RunProcessElement : CustomConfigurationElement
	{
		#region Properties (4)

		/// <summary>
		/// Gets or sets the arguments.
		/// </summary>
		/// <value>
		/// The arguments.
		/// </value>
		[ConfigurationProperty("arguments")]
		[Description("Arguments which should be passed to the process"), Category("Design")]
		public String Arguments
		{
			get { return this["arguments"].ToString(); }
			set { this["arguments"] = value; }
		}

		/// <summary>
		/// Gets or sets the name of the file.
		/// </summary>
		/// <value>
		/// The name of the file.
		/// </value>
		[ConfigurationProperty("fileName", IsRequired = true)]
		[Editor(typeof(System.Windows.Forms.Design.FileNameEditor), typeof(UITypeEditor)), TypeConverter(typeof(ReadOnlyStringConverter))]
		[Description("The proces which should be started"), Category("Design")]
		public String FileName
		{
			get { return this["fileName"].ToString(); }
			set { this["fileName"] = value; }
		}

		/// <summary>
		/// Gets or sets the name.
		/// </summary>
		/// <value>
		/// The name.
		/// </value>
		[ConfigurationProperty("name", IsRequired = true, IsKey = true)]
		public new String Name
		{
			get { return base["name"].ToString(); }
			set
			{
				base["name"] = value;
				base.OnPropertyChanged("Name");
			}
		}

		/// <summary>
		/// Gets or sets the wait minutes after process finished.
		/// </summary>
		/// <value>
		/// The wait minutes after process finished.
		/// </value>
		[ConfigurationProperty("waitSecondsToComplete", IsRequired = false)]
		[Description("Duration to wait for process to complete"), Category("Behavior")]
		public Int32 WaitSecondsToComplete
		{
			get { return Int32.Parse(!String.IsNullOrWhiteSpace(this["waitSecondsToComplete"].ToString()) ? this["waitSecondsToComplete"].ToString() : "0"); }
			set { this["waitSecondsToComplete"] = value; }
		}

		#endregion Properties
	}
}